In Unit 3, you’ll learn how the Twitter Application Programming Interface (API) was used to examine public sentiment around the Common Core and Next Generation Science Standards. The Twitter API facilitates analyses like the by providing companies, developers, and researchers with programmatic access to publicly available data.
For those new to the concept of an API, our very own Raleigh, NC-based Red Hat describes an API as a means for one product or service communicate with other products and services:
APIs are sometimes thought of as contracts, with documentation that represents an agreement between parties: If party 1 sends a remote request structured a particular way, this is how party 2’s software will respond.
As Duke University’s Chris Bail notes, “APIs have become one of the
most important ways to access and transfer data online— and increasingly
APIs can even analyze your data as well.” Compared to screen-scraping
data from web pages, APIs ensure that data is collected legally, and
with R packages like rtweet, they are considerably easier
to work with than HTML or XML data scraped from the web.
For a more in-depth explanation of APIs, how they work, and a preview
of some of the rtweet functions we’ll be using this summer,
I highly recommend reading through Chris Bail’s Application
Programming Interfaces in R tutorial.
In order to use Twitter’s API, you will need to set up a Twitter developer account, which requires a have a regular twitter account. :
Apply for a developer account button.Next, you’ll be asked to confirm and provide some developer information, including a developer account #UseCase.
Student
as your use case and indicating “No” to facilitate
approval.rtweet
package for retrieving data through the Twitter API in R. And should
you determine after the course that you would like to use the Twitter
API for your own research, I highly recommend applying for an Academic
Research account which provides an even greater level of access to
data.Click the Let's do this button to submit a standard
application.
Next, you’ll be prompted to Accept the Terms and Conditions of developer agreement. Check the box and click submit.
- In the prompt provide, give you app any name you like.
R packages such as rtweet
and academictwitteR
that make use the Twitter API v2, which requires an Elevated
Access or Academic
Research account. For this course, an Elevated account will be
sufficient. Complete the following steps to apply:
Below are some suggestions for answering each of the questions you’ll be asked:
In English, please describe how you plan to use Twitter data and/or APIs. The more detailed the response, the easier it is to review and approve.
Are you planning to analyze Twitter data?
Will your app use Tweet, Retweet, Like, Follow, or Direct Message functionality? Please describe your planned use of these features.
Do you plan to display Tweets or aggregate data about Twitter content outside Twitter? Please describe how and where Tweets and/or data about Twitter content will be displayed outside of Twitter.
Will your product, service, or analysis make Twitter content or derived information available to a government entity?
Finally, read through the Developer Agreement, accept the terms, and submit.
Wait for an email from Twitter that should arrive in the next few days that either:
Once your application is approved you can now using the Twitter API. and proceed to the following section!
Before you can begin pulling tweets into R, you’ll first need to
create a Twitter App in your developer account. This section is borrowed
largely from the rtweet package by Michael Kearney, and
requires that you have set up a Twitter developer account.
Follow the steps below to set up your app:
Congratulations!! You’ve completed your Twitter Developer set up and are ready to explore pulling data using the Twitter API in Unit 3!